/**
 * Copyright 2010 upTick Pty Ltd
 *
 * Licensed under the terms of the GNU Lesser General Public License version 3 
 * as published by the Free Software Foundation. You may obtain a copy of the
 * License at: http://www.gnu.org/copyleft/lesser.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations 
 * under the License. 
 */

package au.com.uptick.serendipity.client.sales.view;

import au.com.uptick.serendipity.client.model.ActivityData;
import au.com.uptick.serendipity.client.sales.presenter.ActivitiesPresenter;
import au.com.uptick.serendipity.client.widgets.StatusBar;
import au.com.uptick.serendipity.client.widgets.ToolBar;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewImpl;
import com.smartgwt.client.widgets.layout.VLayout;

public class ActivitiesView extends ViewImpl implements ActivitiesPresenter.MyView {

    private static final String CONTEXT_AREA_WIDTH = "*";

    private final ToolBar toolbar;
    private final ActivitiesContextAreaListGrid listGrid;
    private final StatusBar statusBar;

    private VLayout panel;

    @Inject
    public ActivitiesView(ToolBar toolbar, ActivitiesContextAreaListGrid listGrid,
                          StatusBar statusBar) {

        Log.debug("ActivitiesView()");

        this.toolbar = toolbar;
        this.listGrid = listGrid;
        this.statusBar = statusBar;

        panel = new VLayout();

        // initialise the Activities View layout container
        panel.setStyleName("crm-ContextArea");
        panel.setWidth(CONTEXT_AREA_WIDTH);

        // add the Tool Bar, List Grid, and Status Bar to the Activities View layout container
        panel.addMember(this.toolbar);
        panel.addMember(this.listGrid);
        panel.addMember(this.statusBar);
        // this.addMember(this.jumpBar);
    }

    @Override
    public Widget asWidget() {
        return panel;
    }

    public void setData() {
        listGrid.setData(ActivityData.getRecords());
    }
}
